/**
 * 
 */
package com.lehecai.core.lottery;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.lehecai.core.IntegerBeanLabelItem;

/**
 * @author Sunshow
 * 单场即时SP值
 */
public class DcSPType extends IntegerBeanLabelItem {


	private static final long serialVersionUID = 2465840431256917709L;

	private static final Logger logger = LoggerFactory.getLogger(DcSPType.class.getName());
	
	private static List<DcSPType> items = new ArrayList<DcSPType>();
	
	private static Map<LotteryType, List<DcSPType>> lotteryItemsMap = new HashMap<LotteryType, List<DcSPType>>();
	
	protected DcSPType(String name, int value) {
		this(name, value, null);
	}
	
	protected DcSPType(String name, int value, LotteryType lotteryType) {
		super(DcSPType.class.getName(), name, value);
		items.add(this);
		
		if (lotteryType != null) {
			synchronized(this) {
				List<DcSPType> lotteryItems = lotteryItemsMap.get(lotteryType);
				if (lotteryItems == null) {
					lotteryItems = new ArrayList<DcSPType>();
					lotteryItemsMap.put(lotteryType, lotteryItems);
				}
				lotteryItems.add(this);
			}
		}
	}
	
	public static DcSPType getItem(int value){
		try {
			return (DcSPType)DcSPType.getResult(DcSPType.class.getName(), value);
		} catch (Exception e) {
			logger.error(e.getMessage(), e);
			return null;
		}
	}
	
	public static List<DcSPType> getItems() {
		return items;
	}
	
	public static List<DcSPType> getItems(LotteryType lotteryType) {
		return lotteryItemsMap.get(lotteryType);
	}
	
	private static Map<DcSPType, String> lotteryConstantMap = new HashMap<DcSPType, String>();
	
	public static String getLotteryConstant(DcSPType spType) {
		return lotteryConstantMap.get(spType);
	}
	
	//单场胜负平
	public static final DcSPType SFP_S = new DcSPType("胜平负-胜", 1, LotteryType.DC_SFP);
	public static final DcSPType SFP_F = new DcSPType("胜负平-负",2, LotteryType.DC_SFP);
	public static final DcSPType SFP_P = new DcSPType("胜负平-平",3, LotteryType.DC_SFP);
	
	//单场上下单双
	public static final DcSPType SXDS_SD = new DcSPType("上下单双-上单",4, LotteryType.DC_SXDS);
	public static final DcSPType SXDS_SS = new DcSPType("上下单双-上双",5, LotteryType.DC_SXDS);
	public static final DcSPType SXDS_XD = new DcSPType("上下单双-下单",6, LotteryType.DC_SXDS);
	public static final DcSPType SXDS_XS = new DcSPType("上下单双-下双",7, LotteryType.DC_SXDS);
	
	//单场进球数
	public static final DcSPType JQS_0 = new DcSPType("进球数-0",8, LotteryType.DC_JQS);
	public static final DcSPType JQS_1 = new DcSPType("进球数-1",9, LotteryType.DC_JQS);
	public static final DcSPType JQS_2 = new DcSPType("进球数-2",10, LotteryType.DC_JQS);
	public static final DcSPType JQS_3 = new DcSPType("进球数-3",11, LotteryType.DC_JQS);
	public static final DcSPType JQS_4 = new DcSPType("进球数-4",12, LotteryType.DC_JQS);
	public static final DcSPType JQS_5 = new DcSPType("进球数-5",13, LotteryType.DC_JQS);
	public static final DcSPType JQS_6 = new DcSPType("进球数-6",14, LotteryType.DC_JQS);
	public static final DcSPType JQS_7 = new DcSPType("进球数-7",15, LotteryType.DC_JQS);
	
	//单场比分-胜
	public static final DcSPType BF_S_10 = new DcSPType("比分-胜-10",16, LotteryType.DC_BF);
	public static final DcSPType BF_S_20 = new DcSPType("比分-胜-20",17, LotteryType.DC_BF);
	public static final DcSPType BF_S_21 = new DcSPType("比分-胜-21",18, LotteryType.DC_BF);
	public static final DcSPType BF_S_30 = new DcSPType("比分-胜-30",19, LotteryType.DC_BF);
	public static final DcSPType BF_S_31 = new DcSPType("比分-胜-31",20, LotteryType.DC_BF);
	public static final DcSPType BF_S_32 = new DcSPType("比分-胜-32",21, LotteryType.DC_BF);
	public static final DcSPType BF_S_40 = new DcSPType("比分-胜-40",22, LotteryType.DC_BF);
	public static final DcSPType BF_S_41 = new DcSPType("比分-胜-41",23, LotteryType.DC_BF);
	public static final DcSPType BF_S_42 = new DcSPType("比分-胜-42",24, LotteryType.DC_BF);
	public static final DcSPType BF_S_Other = new DcSPType("比分-胜-其他",25, LotteryType.DC_BF);
	
	//单场比分-平
	public static final DcSPType BF_P_0 = new DcSPType("比分-平-0",26, LotteryType.DC_BF);
	public static final DcSPType BF_P_1 = new DcSPType("比分-平-1",27, LotteryType.DC_BF);
	public static final DcSPType BF_P_2 = new DcSPType("比分-平-2",28, LotteryType.DC_BF);
	public static final DcSPType BF_P_3 = new DcSPType("比分-平-3",29, LotteryType.DC_BF);
	public static final DcSPType BF_P_Other = new DcSPType("比分-平-其他",30, LotteryType.DC_BF);
	
	//单场比分-负
	public static final DcSPType BF_F_01 = new DcSPType("比分-负-01",31, LotteryType.DC_BF);
	public static final DcSPType BF_F_02 = new DcSPType("比分-负-02",32, LotteryType.DC_BF);
	public static final DcSPType BF_F_12 = new DcSPType("比分-负-12",33, LotteryType.DC_BF);
	public static final DcSPType BF_F_03 = new DcSPType("比分-负-03",34, LotteryType.DC_BF);
	public static final DcSPType BF_F_13 = new DcSPType("比分-负-13",35, LotteryType.DC_BF);
	public static final DcSPType BF_F_23 = new DcSPType("比分-负-23",36, LotteryType.DC_BF);
	public static final DcSPType BF_F_04 = new DcSPType("比分-负-04",37, LotteryType.DC_BF);
	public static final DcSPType BF_F_14 = new DcSPType("比分-负-14",38, LotteryType.DC_BF);
	public static final DcSPType BF_F_24 = new DcSPType("比分-负-24",39, LotteryType.DC_BF);
	public static final DcSPType BF_F_Other = new DcSPType("比分-负-其他",40, LotteryType.DC_BF);
	
	//单场半场胜负平
	public static final DcSPType BCSFP_SS = new DcSPType("半场胜负平-胜-胜",41, LotteryType.DC_BCSFP);
	public static final DcSPType BCSFP_SP = new DcSPType("半场胜负平-胜-平",42, LotteryType.DC_BCSFP);
	public static final DcSPType BCSFP_SF = new DcSPType("半场胜负平-胜-负",43, LotteryType.DC_BCSFP);
	public static final DcSPType BCSFP_PS = new DcSPType("半场胜负平-平-胜",44, LotteryType.DC_BCSFP);
	public static final DcSPType BCSFP_PP = new DcSPType("半场胜负平-平-平",45, LotteryType.DC_BCSFP);
	public static final DcSPType BCSFP_PF = new DcSPType("半场胜负平-平-负",46, LotteryType.DC_BCSFP);
	public static final DcSPType BCSFP_FS = new DcSPType("半场胜负平-负-胜",47, LotteryType.DC_BCSFP);
	public static final DcSPType BCSFP_FP = new DcSPType("半场胜负平-负-平",48, LotteryType.DC_BCSFP);
	public static final DcSPType BCSFP_FF = new DcSPType("半场胜负平-负-负",49, LotteryType.DC_BCSFP);

	@Override
	public String toString() {
		return this.name;
	}
	static {
		lotteryConstantMap.put(DcSPType.SFP_S, LotteryConstant.DC_SFP_S_VALUE);
		lotteryConstantMap.put(DcSPType.SFP_P, LotteryConstant.DC_SFP_P_VALUE);
		lotteryConstantMap.put(DcSPType.SFP_F, LotteryConstant.DC_SFP_F_VALUE);
		//lotteryConstantMap.put(DcSPType.SPF_RQ, LotteryConstant.JCZQ_SPF_RQ_VALUE);
		
		lotteryConstantMap.put(DcSPType.BF_S_10, LotteryConstant.DC_BF_S_10_VALUE);
		lotteryConstantMap.put(DcSPType.BF_S_20, LotteryConstant.DC_BF_S_20_VALUE);
		lotteryConstantMap.put(DcSPType.BF_S_21, LotteryConstant.DC_BF_S_21_VALUE);
        lotteryConstantMap.put(DcSPType.BF_S_30, LotteryConstant.DC_BF_S_30_VALUE);
		lotteryConstantMap.put(DcSPType.BF_S_31, LotteryConstant.DC_BF_S_31_VALUE);
		lotteryConstantMap.put(DcSPType.BF_S_32, LotteryConstant.DC_BF_S_32_VALUE);
        lotteryConstantMap.put(DcSPType.BF_S_40, LotteryConstant.DC_BF_S_40_VALUE);
		lotteryConstantMap.put(DcSPType.BF_S_41, LotteryConstant.DC_BF_S_41_VALUE);
		lotteryConstantMap.put(DcSPType.BF_S_42, LotteryConstant.DC_BF_S_42_VALUE);
        lotteryConstantMap.put(DcSPType.BF_S_Other, LotteryConstant.DC_BF_S_Ohter_VALUE);
		lotteryConstantMap.put(DcSPType.BF_P_0, LotteryConstant.DC_BF_P_0_VALUE);
		lotteryConstantMap.put(DcSPType.BF_P_1, LotteryConstant.DC_BF_P_1_VALUE);
        lotteryConstantMap.put(DcSPType.BF_P_2, LotteryConstant.DC_BF_P_2_VALUE);
		lotteryConstantMap.put(DcSPType.BF_P_3, LotteryConstant.DC_BF_P_3_VALUE);
		lotteryConstantMap.put(DcSPType.BF_P_Other, LotteryConstant.DC_BF_P_Other_VALUE);
        lotteryConstantMap.put(DcSPType.BF_F_01, LotteryConstant.DC_BF_F_01_VALUE);
		lotteryConstantMap.put(DcSPType.BF_F_02, LotteryConstant.DC_BF_F_02_VALUE);
		lotteryConstantMap.put(DcSPType.BF_F_12, LotteryConstant.DC_BF_F_12_VALUE);
		lotteryConstantMap.put(DcSPType.BF_F_03, LotteryConstant.DC_BF_F_03_VALUE);
        lotteryConstantMap.put(DcSPType.BF_F_13, LotteryConstant.DC_BF_F_13_VALUE);
		lotteryConstantMap.put(DcSPType.BF_F_23, LotteryConstant.DC_BF_F_23_VALUE);
		lotteryConstantMap.put(DcSPType.BF_F_04, LotteryConstant.DC_BF_F_04_VALUE);
        lotteryConstantMap.put(DcSPType.BF_F_14, LotteryConstant.DC_BF_F_14_VALUE);
		lotteryConstantMap.put(DcSPType.BF_F_24, LotteryConstant.DC_BF_F_24_VALUE);
		lotteryConstantMap.put(DcSPType.BF_F_Other, LotteryConstant.DC_BF_F_Other_VALUE);
		
		lotteryConstantMap.put(DcSPType.JQS_0, LotteryConstant.DC_JQX_0_VALUE);
		lotteryConstantMap.put(DcSPType.JQS_1, LotteryConstant.DC_JQX_1_VALUE);
		lotteryConstantMap.put(DcSPType.JQS_2, LotteryConstant.DC_JQX_2_VALUE);
		lotteryConstantMap.put(DcSPType.JQS_3, LotteryConstant.DC_JQX_3_VALUE);
		lotteryConstantMap.put(DcSPType.JQS_4, LotteryConstant.DC_JQX_4_VALUE);
		lotteryConstantMap.put(DcSPType.JQS_5, LotteryConstant.DC_JQX_5_VALUE);
		lotteryConstantMap.put(DcSPType.JQS_6, LotteryConstant.DC_JQX_6_VALUE);
		lotteryConstantMap.put(DcSPType.JQS_7, LotteryConstant.DC_JQX_7_VALUE);
		
		lotteryConstantMap.put(DcSPType.BCSFP_SS, LotteryConstant.DC_BCSFP_SS_VALUE);
		lotteryConstantMap.put(DcSPType.BCSFP_SP, LotteryConstant.DC_BCSFP_SP_VALUE);
		lotteryConstantMap.put(DcSPType.BCSFP_SF, LotteryConstant.DC_BCSFP_SF_VALUE);
		lotteryConstantMap.put(DcSPType.BCSFP_PS, LotteryConstant.DC_BCSFP_PS_VALUE);
		lotteryConstantMap.put(DcSPType.BCSFP_PP, LotteryConstant.DC_BCSFP_PP_VALUE);
		lotteryConstantMap.put(DcSPType.BCSFP_PF, LotteryConstant.DC_BCSFP_PF_VALUE);
		lotteryConstantMap.put(DcSPType.BCSFP_FS, LotteryConstant.DC_BCSFP_FS_VALUE);
		lotteryConstantMap.put(DcSPType.BCSFP_FP, LotteryConstant.DC_BCSFP_FP_VALUE);
		lotteryConstantMap.put(DcSPType.BCSFP_FF, LotteryConstant.DC_BCSFP_FF_VALUE);
		
		lotteryConstantMap.put(DcSPType.SXDS_SD, LotteryConstant.DC_SXDS_SD_VALUE);
		lotteryConstantMap.put(DcSPType.SXDS_SS, LotteryConstant.DC_SXDS_SS_VALUE);
		lotteryConstantMap.put(DcSPType.SXDS_XD, LotteryConstant.DC_SXDS_XD_VALUE);
		lotteryConstantMap.put(DcSPType.SXDS_XS, LotteryConstant.DC_SXDS_XS_VALUE);
	}
}
